# -*-coding: Utf-8 -*-
# @File : matplotlib_common .py
# author: Chimengmeng
# blog_url : https://www.cnblogs.com/dream-ze/
# Time：2023/9/3
import matplotlib.pyplot as plt


class CommonMatplot():

    def create_circle(self, **kwargs):
        labels = []
        sizes = []

        if kwargs:
            for label, size in kwargs.items():
                labels.append(label)
                sizes.append(size)

        if sizes:
            fig, ax = plt.subplots()
            ax.pie(sizes, labels=labels, autopct='%1.1f%%', startangle=90)
            ax.axis('equal')  # Equal aspect ratio ensures that pie is drawn as a circle.
            plt.show()
        else:
            print("数据不足!")


if __name__ == '__main__':
    # labels = 'Frogs', 'Hogs', 'Dogs', 'Logs'
    # sizes = [15, 30, 45, 10]
    com = CommonMatplot()
    com.create_circle(Frogs=15, Hogs=30)
